package bairui.international.weixin.portal.miniapp.controller.ticket.offset;

import java.text.SimpleDateFormat;

import bairui.international.model.domain.jpa.TB_ElectronicTicket;
import bairui.international.model.domain.jpa.TB_ElectronicTicketOrder;
import bairui.international.model.status.State_ElectronicTicket;
import bairui.international.model.type.Type_ElectronicTicket;
import lombok.Getter;
import lombok.NoArgsConstructor;

@NoArgsConstructor
public class Output {
		
		@Getter private Long id;
		@Getter private String name;
		@Getter private State_ElectronicTicket state;
		@Getter private String dimensionalUrl;
		@Getter private String stateComment;
		@Getter private Boolean giveFlag;
		@Getter private Boolean oneuseFlag;
		@Getter private String number;
//		@Getter private String comment;
		@Getter private Type_ElectronicTicket type;
		@Getter private Double price;
		@Getter private String typeComment;
//		@Getter private Long assignedUserId;
		@Getter private Boolean isAssigner; 	// 是否为配发者
		@Getter private Boolean isTaker;		// 是否为领取者
		@Getter private Integer transmitCount;
		
		@Getter private String assignDate;
		@Getter private String takeDate;
		@Getter private String expiryDate;
		@Getter private String useDate;
		@Getter private String generateDate;
		
		public Output(TB_ElectronicTicket bean, String skey){
			TB_ElectronicTicketOrder order = bean.getElectronicTicketOrder();
			this.id = bean.getId();
			this.number = bean.getNumber();
			this.state = bean.getState();
//			this.dimensionalUrl = bean.getDimensionalUrl();
			this.dimensionalUrl = new C_Ticket_Offset_ShowQRImg_ShowImg.ShowImg.Operate() {
					@Override public Object getId() {
						return bean.getId();
					}
				}.operate().getUrl();
			this.stateComment = bean.getState().getComment();
			this.isAssigner =  null != bean.getAssignedUser() && bean.getAssignedUser().getSkey().equals(skey);
			this.isTaker = null != bean.getTakor() && bean.getTakor().getSkey().equals(skey);
			this.transmitCount = bean.getTransmitCount();
			// 时间
			this.assignDate = bean.getAssignDate()==null ? null : new SimpleDateFormat("yyyy/MM/dd hh:mm:ss").format(bean.getAssignDate());
			this.useDate = bean.getUseDate()==null ? null : new SimpleDateFormat("yyyy/MM/dd hh:mm:ss").format(bean.getUseDate());
			this.takeDate = bean.getTakeDate()==null ? null : new SimpleDateFormat("yyyy/MM/dd hh:mm:ss").format(bean.getTakeDate());
			this.generateDate = new SimpleDateFormat("yyyy/MM/dd").format(order.getGenerateDate());
			this.expiryDate = new SimpleDateFormat("yyyy/MM/dd").format(order.getExpiryDate());
			//
			this.name = order.getName();
			this.giveFlag = order.getGiveFlag();
			this.oneuseFlag = order.getOneuseFlag();
//			this.comment = order.getComment();
			this.type = order.getType();
			this.typeComment = order.getType().getComment();
			this.price = order.getPrice();
		}
	}